package ui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JList;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;

import node.NodeDescriptor;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import discoveryServer.*;

public class DiscoveryUi {

	private JFrame frame;
	private JTextField textFieldTimeout;
	private JButton btnSet;
	private JList list;
		
	
	public JList getList(){
		return this.list;
	}
		
	public JButton getBtnSet(){
		return this.btnSet;
	}
	

	
	public JFrame getFrame(){
		return this.frame;
	}
	
	public JTextField getFieldTimeout(){
		return this.textFieldTimeout;
	}
	
	
	/**
	 * Create the application.
	 */
	public DiscoveryUi() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 253, 441);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(0, 0, 253, 89);
		frame.getContentPane().add(panel);
		panel.setLayout(null);
		
		textFieldTimeout = new JTextField();
		textFieldTimeout.setBounds(126, 33, 46, 28);
		System.out.println(NodeDescriptor.getInstance().getD_timeout());
		textFieldTimeout.setText(String.valueOf(NodeDescriptor.getInstance().getD_timeout()));
		panel.add(textFieldTimeout);
		textFieldTimeout.setColumns(10);
		
		
		//System.out.println(NodeDescriptor.getInstance().getD_timeout());
		
		
		JLabel lblDiscoveryTimeout = new JLabel("Discovery timeout");
		lblDiscoveryTimeout.setBounds(6, 39, 129, 16);
		panel.add(lblDiscoveryTimeout);
		
		btnSet = new JButton("Set");
		
		btnSet.setBounds(174, 34, 73, 28);
		panel.add(btnSet);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(0, 87, 253, 326);
		frame.getContentPane().add(panel_1);
		GridBagLayout gbl_panel_1 = new GridBagLayout();
		gbl_panel_1.columnWidths = new int[]{0, 0};
		gbl_panel_1.rowHeights = new int[]{0, 0};
		gbl_panel_1.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gbl_panel_1.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		panel_1.setLayout(gbl_panel_1);
		
		list = new JList();
		GridBagConstraints gbc_list = new GridBagConstraints();
		gbc_list.fill = GridBagConstraints.BOTH;
		gbc_list.gridx = 0;
		gbc_list.gridy = 0;
		panel_1.add(list, gbc_list);
	}
}
